package com.aaa.car.util;

/**
 * @fileName.OperationLogUtil
 * @description:
 * @author:zwl
 * @createTime:2020/11/12 14:06
 * @version:1.0.0
 */
/*@Component
@Aspect    //标志为切面实现类，即通知类
public class OperationLogUtil {*/
    /**
     * 依赖注入服务
     */
   /* @Autowired
    private OperLogService operLogService;*/
    /**
     * 注入获取session
     */
    /*@Autowired
    private HttpSession session;*/

    //后置通知，方法运行后执行
    /*@AfterReturning(pointcut = "execution(* com.aaa.power.service.*.insert*(..))execution(* com.aaa.power.service.*.update*(..))||execution(* com.aaa.power.service.*.deleteById*(..)))")
    public void recordOperationLog(JoinPoint joinPoint){
        OperLog operLog=new OperLog();
        operLog.setTitle("权限管理");
        //获取方法名称
        String methodName = joinPoint.getSignature().getName();
        int businessType=0;
        if(methodName.startsWith("insert")){
            //如果为新增方法，为1
            businessType=1;
        }else if (methodName.startsWith("update")){
            //如果为修改方法，为2
            businessType=2;
        }else{
            //如果为删除方法，为3
            businessType=3;
        }
        operLog.setBusinessType(businessType);
        //方法名称  类的限定名+方法名称
        //获取类的名称
        String className = joinPoint.getTarget().getClass().getName();
        operLog.setMethod(className+"."+methodName+"()");
        //操作类型
        operLog.setOperatorType(1);
        //设置操作用户和部门
        User user=session.getAttribute("userInfo")==null?null:(User)session.getAttribute("userInfo");
        if (user!=null){
            operLog.setOperName(user.getLoginName());
            operLog.setDeptName(user.getDeptId()+"");
        }
        //获取request对象
        RequestAttributes requestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        operLogService.insert(operLog);
    }
}
*/